<template>
  <j-modal title="详情" :width="700" :visible="visible" switchFullscreen @cancel="handleCancel" @ok="handleOk">
    <a-tabs default-active-key="1" @change="onTabChange">
      <a-tab-pane key="1" tab="计划详情">
        <p>计划类型：{{ infoObj.planType }}</p>
        <p>计划内容：{{ infoObj.planContent }}</p>
        <p class="pt">行动计划表</p>
        <p>计划时间：{{ infoObj.planStartTime }} ~ {{ infoObj.planEndTime }}</p>
        <p>介入类型：{{ setTittle(infoObj.typeIntervention) }}</p>
        <p>任务量：{{ infoObj.taskVolume }}</p>
        <p>完成量：{{ infoObj.completedQuantity }}</p>
        <p class="pt">预计困难/风险</p>
        <p>{{ infoObj.risk }}</p>
        <p class="pt">预案</p>
        <p>{{ infoObj.reserve }}</p>
        <p class="pt">投入咨询</p>
        <p>{{ infoObj.inputResourses }}</p>
        <p class="pt">预算</p>
        <p>{{ infoObj.budget }}</p>
      </a-tab-pane>
      <a-tab-pane key="2" tab="完成情况">
        <z-table ref="table" rowKey="id" :showAlert="false" :showSelection="false" :loading="loading" :columns="columns"
          :dataSource="pageData" @change="onTableChange" style="margin-top:20px;">
        </z-table>
      </a-tab-pane>
    </a-tabs>
    <template slot="footer">
      <p style="text-align: left;">创建人：{{ infoObj.createName }} <span style="margin-left:30px;">创建时间：{{
          infoObj.createTime
      }}</span> </p>
    </template>
  </j-modal>
</template>
<script>
import * as helpApi from '@/api/sjsk/help/helpPlan.js'
export default {
  name: 'detailModal',
  data() {
    return {
      visible: false,
      loading: false,
      columns: [],
      columns1: [
        {
          title: '序号',
          dataIndex: 'order',
          width: 60,
          align: 'center',
          customRender: (text, record, index) =>
            `${(this.pageFilter.pageNo - 1) * this.pageFilter.pageSize + (index + 1)}` //序号分页后连续
        },
        {
          title: '检测次数',
          dataIndex: 'numberOfTests',
          align: 'center',
        },
        {
          title: '检测类型',
          dataIndex: 'testType',
          align: 'testType',
          scopedSlots: { customRender: 'testType' }
        },
        {
          title: '检测结果',
          dataIndex: 'detectionResult',
          align: 'center',
        },
        {
          title: '检测时间',
          dataIndex: 'detectionTime',
          align: 'center',
        },
      ],
      columns2: [
        {
          title: '序号',
          dataIndex: 'order',
          width: 60,
          align: 'center',
          customRender: (text, record, index) =>
            `${(this.pageFilter.pageNo - 1) * this.pageFilter.pageSize + (index + 1)}` //序号分页后连续
        },
        {
          title: '检测次数',
          dataIndex: 'numberOfTests',
          align: 'center',
        },
        {
          title: '检测类型',
          dataIndex: 'testType',
          align: 'center',
          scopedSlots: { customRender: 'testType' }
        },
        {
          title: '初筛结果',
          dataIndex: 'preliminaryScreeningResults',
          align: 'center',
        },
        {
          title: '司法结果',
          dataIndex: 'judicialOutcomes',
          align: 'center',
        },
        {
          title: '检测时间',
          dataIndex: 'detectionTime',
          align: 'center',
        },
      ],
      columns3: [
        {
          title: '序号',
          dataIndex: 'order',
          width: 60,
          align: 'center',
          customRender: (text, record, index) =>
            `${(this.pageFilter.pageNo - 1) * this.pageFilter.pageSize + (index + 1)}` //序号分页后连续
        },
        {
          title: '访谈次数',
          dataIndex: 'numberOfInterviews',
          align: 'center',
        },
        {
          title: '访谈分类',
          dataIndex: 'interviewClassification',
          align: 'center',
        },
        {
          title: '访谈人员',
          dataIndex: 'interviewers',
          align: 'center',
        },
        {
          title: '谈话时间',
          dataIndex: 'talkTime',
          align: 'center',
        },
      ],
      columns4: [
        {
          title: '序号',
          dataIndex: 'order',
          width: 60,
          align: 'center',
          customRender: (text, record, index) =>
            `${(this.pageFilter.pageNo - 1) * this.pageFilter.pageSize + (index + 1)}` //序号分页后连续
        },
        {
          title: '访谈次数',
          dataIndex: 'numberOfInterviews',
          align: 'center',
        },
        {
          title: '访谈分类',
          dataIndex: 'interviewClassification',
          align: 'center',
        },
        {
          title: '访谈人员',
          dataIndex: 'interviewers',
          align: 'center',
        },
        {
          title: '谈话时间',
          dataIndex: 'talkTime',
          align: 'center',
        },
      ],
      columns5: [
        {
          title: '序号',
          dataIndex: 'order',
          width: 60,
          align: 'center',
          customRender: (text, record, index) =>
            `${(this.pageFilter.pageNo - 1) * this.pageFilter.pageSize + (index + 1)}` //序号分页后连续
        },
        {
          title: '报告次数',
          dataIndex: 'numberOfReports',
          align: 'center',
        },
        {
          title: '提交时间',
          dataIndex: 'submissionTime',
          align: 'center',
        },
      ],
      columns6: [
        {
          title: '序号',
          dataIndex: 'order',
          width: 60,
          align: 'center',
          customRender: (text, record, index) =>
            `${(this.pageFilter.pageNo - 1) * this.pageFilter.pageSize + (index + 1)}` //序号分页后连续
        },
        {
          title: '活动时间',
          dataIndex: 'activityTime',
          align: 'center',
        },
        {
          title: '活动性质',
          dataIndex: 'natureOfActivities',
          align: 'center',
        },
        {
          title: '活动名称',
          dataIndex: 'activityName',
          align: 'center',
        },
        {
          title: '活动地点',
          dataIndex: 'venue',
          align: 'center',
        },
      ],
      columns7: [
        {
          title: '序号',
          dataIndex: 'order',
          width: 60,
          align: 'center',
          customRender: (text, record, index) =>
            `${(this.pageFilter.pageNo - 1) * this.pageFilter.pageSize + (index + 1)}` //序号分页后连续
        },
        {
          title: '活动时间',
          dataIndex: 'activityTime',
          align: 'center',
        },
        {
          title: '活动性质',
          dataIndex: 'natureOfActivities',
          align: 'center',
        },
        {
          title: '活动名称',
          dataIndex: 'activityName',
          align: 'center',
        },
        {
          title: '活动地点',
          dataIndex: 'activityName',
          align: 'center',
        },
      ],
      columns8: [
        {
          title: '序号',
          dataIndex: 'order',
          width: 60,
          align: 'center',
          customRender: (text, record, index) =>
            `${(this.pageFilter.pageNo - 1) * this.pageFilter.pageSize + (index + 1)}` //序号分页后连续
        },
        {
          title: '救助类型',
          dataIndex: 'salvageType',
          align: 'center',
        },
        {
          title: '救助起止时间',
          dataIndex: 'startingAndEndingTimeOfRescue',
          align: 'center',
        },
      ],
      columns91: [
        {
          title: '序号',
          dataIndex: 'order',
          width: 60,
          align: 'center',
          customRender: (text, record, index) =>
            `${(this.pageFilter.pageNo - 1) * this.pageFilter.pageSize + (index + 1)}` //序号分页后连续
        },
        {
          title: '工种名称',
          dataIndex: 'typeOfWork',
          align: 'center',
        },
        {
          title: '培训等级',
          dataIndex: 'trainingLevel',
          align: 'center',
        },
        {
          title: '培训开始时间',
          dataIndex: 'trainingStartTime',
          align: 'center',
        },
        {
          title: '培训结束时间',
          dataIndex: 'trainingEndTime',
          align: 'center',
        },
      ],
      columns92: [
        {
          title: '序号',
          dataIndex: 'order',
          width: 60,
          align: 'center',
          customRender: (text, record, index) =>
            `${(this.pageFilter.pageNo - 1) * this.pageFilter.pageSize + (index + 1)}` //序号分页后连续
        },
        {
          title: '工种名称',
          dataIndex: 'typeOfWork',
          align: 'center',
        },
        {
          title: '等级名称',
          dataIndex: 'trainLevel',
          align: 'center',
        },
        {
          title: '证书名称',
          dataIndex: 'certificateName',
          align: 'center',
        },
        {
          title: '发证日期',
          dataIndex: 'dateOfIssue',
          align: 'center',
        },
      ],
      columns10: [
        {
          title: '序号',
          dataIndex: 'order',
          width: 60,
          align: 'center',
          customRender: (text, record, index) =>
            `${(this.pageFilter.pageNo - 1) * this.pageFilter.pageSize + (index + 1)}` //序号分页后连续
        },
        {
          title: '就业单位',
          dataIndex: 'employmentUnit',
          align: 'center',
        },
        {
          title: '就业时间',
          dataIndex: 'employmentTime',
          align: 'center',
        },
        {
          title: '就业地点',
          dataIndex: 'placeOfEmployment',
          align: 'center',
        },
        {
          title: '就业类型',
          dataIndex: 'employmentType',
          align: 'center',
        },
      ],
      columns11: [
        {
          title: '序号',
          dataIndex: 'order',
          width: 60,
          align: 'center',
          customRender: (text, record, index) =>
            `${(this.pageFilter.pageNo - 1) * this.pageFilter.pageSize + (index + 1)}` //序号分页后连续
        },
        {
          title: '咨询次数',
          dataIndex: 'numberOfConsultations',
          align: 'center',
        },
        {
          title: '咨询主题',
          dataIndex: 'consultingTopic',
          align: 'center',
        },
        {
          title: '咨询时间',
          dataIndex: 'consultingTime',
          align: 'center',
        },
        {
          title: '谈话方式',
          dataIndex: 'conversationStyle',
          align: 'center',
        },
      ],
      columns12: [
        {
          title: '序号',
          dataIndex: 'order',
          width: 60,
          align: 'center',
          customRender: (text, record, index) =>
            `${(this.pageFilter.pageNo - 1) * this.pageFilter.pageSize + (index + 1)}` //序号分页后连续
        },
        {
          title: '咨询次数',
          dataIndex: 'numberOfConsultations',
          align: 'center',
        },
        {
          title: '咨询主题',
          dataIndex: 'consultingTopic',
          align: 'center',
        },
        {
          title: '咨询时间',
          dataIndex: 'consultingTime',
          align: 'center',
        },
        {
          title: '谈话方式',
          dataIndex: 'conversationStyle',
          align: 'center',
        },
      ],
      columns13: [
        {
          title: '序号',
          dataIndex: 'order',
          width: 60,
          align: 'center',
          customRender: (text, record, index) =>
            `${(this.pageFilter.pageNo - 1) * this.pageFilter.pageSize + (index + 1)}` //序号分页后连续
        },
        {
          title: '服药次数',
          dataIndex: 'timesOfAdministration',
          align: 'center',
        },
        {
          title: '服药时间',
          dataIndex: 'administrationTime',
          align: 'center',
        },
        {
          title: '药物批号',
          dataIndex: 'drugBatchNumber',
          align: 'center',
        },
        {
          title: '当前剂量',
          dataIndex: 'doseCurrent',
          align: 'center',
        },
        {
          title: '医生编号',
          dataIndex: 'doctorNo',
          align: 'center',
        },
      ],
      pageFilter: {
        pageNo: 1,
        pageSize: 10,
      },
      pageData: {},
      infoObj: {},
      params: {},
      typeIntervention: ''
    }
  },
  async created() {
  },
  methods: {
    show(record) {
      this.visible = true
      this.infoObj = record
      this.params = {
        id: record.id,
        personPlanId: record.helpPlanId,
        typeIntervention: record.typeIntervention,
        startTime: record.planStartTime,
        endTime: record.planEndTime
      }
      if (record.typeIntervention == '1') this.columns = this.columns1  //尿液检测
      if (record.typeIntervention == '2') this.columns = this.columns2  //毛发检测
      if (record.typeIntervention == '3') this.columns = this.columns3  //定期访谈
      if (record.typeIntervention == '4') this.columns = this.columns4  //帮教谈心	
      if (record.typeIntervention == '5') this.columns = this.columns5  //定期报告
      if (record.typeIntervention == '6') this.columns = this.columns6  //社区活动
      if (record.typeIntervention == '7') this.columns = this.columns7  //小组活动
      if (record.typeIntervention == '8') this.columns = this.columns8  //帮扶救助
      if (record.typeIntervention == '9') this.columns = this.columns91  //职业技能培训（待培训）
      if (record.typeIntervention == '9') this.columns = this.columns92  //职业技能培训（已培训）
      if (record.typeIntervention == '10') this.columns = this.columns10 //就业安置
      if (record.typeIntervention == '11') this.columns = this.columns11 //法律援助	
      if (record.typeIntervention == '12') this.columns = this.columns12 //心理咨询	
      if (record.typeIntervention == '13') this.columns = this.columns13 //美沙酮治疗	
    },
    onTabChange(val) {
      if (val == 2) {
        this.getDetail()
      }
    },
    getDetail() {
      helpApi.viewActions(this.params).then(res => {
        if (res.success) {
          this.pageData = res.result
        }
      })
    },
    onQuery() {
      this.pageFilter.pageNo = 1
      this.refreshTable()
    },
    onTableChange(pagination, pageFilter, sorter) {
      let keyMap = { currentPage: 'pageNo' }
      let paginations = Object.keys(pagination).reduce((newData, key) => {
        let newKey = keyMap[key] || key
        newData[newKey] = pagination[key]
        return newData
      }, {})
      this.pageFilter = Object.assign({}, this.pageFilter, paginations)
      this.refreshTable()
    },
    refreshTable() {
      this.loading = true
      peopleApi
        .wxSeedPersonList(this.pageFilter)
        .then((res) => {
          if (res.success) {
            this.pageData = res.result ? res.result : {}
            this.loading = false
          } else {
            this.loading = false
          }
        })
        .catch((e) => {
          this.loading = false
          this.$message.warn('请求失败！')
        })
    },
    setTittle(text) {
      return this.$filterDictTextByCache('typeIntervention', text)  //现在字典中对应的文字，是全局函数
    },
    handleCancel() {
      this.visible = false
    },
    handleOk() {
      this.visible = false
    }
  },
}
</script>
<style lang="less" scoped>
/deep/ .ant-modal-footer {
  display: flex;
  justify-content: space-between;
}

.pt {
  font-weight: bold;
}

/deep/.ant-modal-body {
  padding-top: 0;
}
</style>
